package com.monboo.album.view.component
{
	import com.monboo.album.command.AlbumEvent;
	
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IOErrorEvent;
	import flash.net.*;
	import flash.system.LoaderContext;

	public class LoadImage extends EventDispatcher
	{
		private var lcontex:LoaderContext;
		private var ld:Loader;
		public var data:Bitmap = new Bitmap();
		
		public function LoadImage()
		{
			lcontex = new LoaderContext;
			lcontex.checkPolicyFile = true;
			
			ld = new Loader();
			
		}
		public function load(url:String):void{
			
			ld.load(new URLRequest(url),lcontex);
			ld.contentLoaderInfo.addEventListener(Event.COMPLETE,loadedImageFun);
			ld.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
		}
		private function ioErrorHandler(e:IOErrorEvent):void {
			//;
		}
		private function loadedImageFun(e:Event):void{	
			data = new Bitmap(e.target.loader.content["bitmapData"],"auto",true);
			dispatchEvent(new Event(AlbumEvent.LOAD_IMAGE_COMPLETE));	
		}
		
	}
}